package com.film.filmweb.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.film.common.annotation.Log;
import com.film.common.core.controller.BaseController;
import com.film.common.core.domain.AjaxResult;
import com.film.common.enums.BusinessType;
import com.film.filmweb.domain.MovieBanner;
import com.film.filmweb.service.IMovieBannerService;
import com.film.common.utils.poi.ExcelUtil;
import com.film.common.core.page.TableDataInfo;

/**
 * 首页bannerController
 * 
 * @author ruoyi
 * @date 2025-09-05
 */
@RestController
@RequestMapping("/movie/banner")
public class MovieBannerController extends BaseController
{
    @Autowired
    private IMovieBannerService movieBannerService;

    /**
     * 查询首页banner列表
     */
    @PreAuthorize("@ss.hasPermi('movie:banner:list')")
    @GetMapping("/list")
    public TableDataInfo list(MovieBanner movieBanner)
    {
        startPage();
        List<MovieBanner> list = movieBannerService.selectMovieBannerList(movieBanner);
        return getDataTable(list);
    }

    /**
     * 导出首页banner列表
     */
    @PreAuthorize("@ss.hasPermi('movie:banner:export')")
    @Log(title = "首页banner", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MovieBanner movieBanner)
    {
        List<MovieBanner> list = movieBannerService.selectMovieBannerList(movieBanner);
        ExcelUtil<MovieBanner> util = new ExcelUtil<MovieBanner>(MovieBanner.class);
        util.exportExcel(response, list, "首页banner数据");
    }

    /**
     * 获取首页banner详细信息
     */
    @PreAuthorize("@ss.hasPermi('movie:banner:query')")
    @GetMapping(value = "/{bannerId}")
    public AjaxResult getInfo(@PathVariable("bannerId") Integer bannerId)
    {
        return success(movieBannerService.selectMovieBannerByBannerId(bannerId));
    }

    /**
     * 新增首页banner
     */
    @PreAuthorize("@ss.hasPermi('movie:banner:add')")
    @Log(title = "首页banner", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MovieBanner movieBanner)
    {
        return toAjax(movieBannerService.insertMovieBanner(movieBanner));
    }

    /**
     * 修改首页banner
     */
    @PreAuthorize("@ss.hasPermi('movie:banner:edit')")
    @Log(title = "首页banner", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MovieBanner movieBanner)
    {
        return toAjax(movieBannerService.updateMovieBanner(movieBanner));
    }

    /**
     * 删除首页banner
     */
    @PreAuthorize("@ss.hasPermi('movie:banner:remove')")
    @Log(title = "首页banner", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bannerIds}")
    public AjaxResult remove(@PathVariable Integer[] bannerIds)
    {
        return toAjax(movieBannerService.deleteMovieBannerByBannerIds(bannerIds));
    }
}
